using System.Collections.Generic;
using AtomicCms.Common.Entities;
using AtomicCms.Common.IDataContext;
using AtomicCms.Common.Models;
using AtomicCms.Data.Concrete;
using NHibernate;

namespace AtomicCms.Data.Repository
{
    public class AtomicCmsRepository : NHSession, IAtomicCmsDataRepository
    {
        #region IAtomicCmsDataRepository Members

        public IEnumerable<PageTag> GetPagesTags()
        {
            return base.LoadAll<PageTag>();
        }

        public IEnumerable<CmsPage> GetPagesWithTag(string tag)
        {
            // todo: update this to avoid using SQLQuery
            ISession session = GetSession();

            var pages = session.GetNamedQuery("GetPagesWithTag").SetString("tag", tag).List<CmsPage>();
            return pages;
        }

        #endregion
    }
}